package com.ca.ridersclubapplication.util;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.View;

public class TransitionUtils {

    public static void fadeInView(View view) {
        view.setVisibility(View.VISIBLE);
        view.setAlpha(0);
        int duration = view.getResources().getInteger(android.R.integer.config_shortAnimTime);
        view.animate()
                .alpha(1f)
                .setDuration(duration)
                .setListener(null);
    }

    public static void fadeOutView(View view) {
        int duration = view.getResources().getInteger(android.R.integer.config_shortAnimTime);
        view.animate()
                .alpha(0)
                .setDuration(duration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        view.setVisibility(View.GONE);
                    }
                });
    }
}
